package com.example.exam.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.exam.entity.ExamList;
import com.example.exam.service.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zhang
 */
@RestController
@RequestMapping("/ks")
public class ExamController {

    @Autowired
    private ExamService examService;

    //test
    //get
    @GetMapping("/Exam{id}")
    public ResponseEntity<IPage<ExamList>> getExamList(@PathVariable Integer id) {
        return ResponseEntity.ok(examService.getExamList(id));
    }

    //export
    @GetMapping("/export/{name}")
    public void export(@PathVariable String name, HttpServletResponse response) throws IOException {
        response.sendRedirect("https://4399.com");
    }

}
